package com.icangya.DAO.impl;

import com.icangya.DAO.IFbUserMobileDAO;

import com.icangya.domain.FBUserMobile;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class FbUserMobileDAOImpl  extends  BaseDAO<FBUserMobile> implements IFbUserMobileDAO {


    /**
     * 使用手机号码和密码，查询用户信息
     * @param mobilePhone
     * @param password
     * @return
     */
    @Override
    public List<FBUserMobile> queryUserByMobilePhoneAndPassword(long mobilePhone, String password){

//        SELECT mo.id, mo.mobilePhone, mo.openid, mo.password, mo.createTime
        String hql=" FROM FBUserMobile mo where mo.mobilePhone = ? and mo.password = ? ";

        List<FBUserMobile> result= (List<FBUserMobile>) getHibernateTemplate().find(hql,mobilePhone,password);

//        int res=Integer.parseInt(result==null?"":result.toString());

        return result ;

    }

    @Override
    public int updateMobilePhone(String mobilePhone) {
        return 0;
    }


    @Override
    public List<FBUserMobile> queryMobilePhoneByOpenid(String openid) {
        String hql=" FROM FBUserMobile mo where mo.openid = ? ";

        List<FBUserMobile> result= (List<FBUserMobile>) getHibernateTemplate().find(hql,openid);

//        int res=Integer.parseInt(result==null?"":result.toString());

        return result ;
    }

    @Override
    public List<FBUserMobile> queryMobilePhoneByMobilePhone(long mobilePhone) {

        String hql=" FROM FBUserMobile mo where mo.mobilePhone = ? ";

        List<FBUserMobile> result= (List<FBUserMobile>) getHibernateTemplate().find(hql,mobilePhone);

//        int res=Integer.parseInt(result==null?"":result.toString());

        return result ;
    }


}
